package com.altorithm;

/**
 * @Classname SelectedSort
 * @Date 2019/9/25 10:20
 * @auther by hqy
 */
public class SelectedSort {

    public static void sort(int[] array) {

        for (int i = 0; i < array.length; i++) {
            int minValue = array[i];
            int minIndex = i;
            for (int j = i + 1; j < array.length; j++) {
                if (array[j] < minValue) {
                    minValue = array[j];
                    minIndex = j;
                }
            }
            if (minIndex != i) {
                array[minIndex] = array[i];

                array[i] = minValue;
            }


        }

    }

}
